
package extensions;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.TableCellRenderer;

/**
 * 
 * @author Raed Shomali
 */
public class COINCOMOClefTableCellRenderer extends JLabel implements TableCellRenderer
{
    public COINCOMOClefTableCellRenderer()
    {
        // to Apply Font and Color ...
        setOpaque( true ) ;
        
        setFont( new Font( "courier" , 0 , 12 ) ) ;
    }

    public Component getTableCellRendererComponent( JTable table , Object value , boolean isSelected , boolean hasFocus , int rowIndex , int colIndex )
    {
        if( colIndex == 1 || colIndex == 2 || colIndex == 3 || colIndex == 4 || colIndex == 5 || colIndex == 6 || colIndex == 7 || colIndex == 8 || colIndex == 9)
        {  
            setBackground( new Color( 255 , 255 , 0 , 130 ) ) ;
        }
        else
        {
            setBackground( Color.decode( "#DDDDDD" ) ) ;
        }
        
        setHorizontalAlignment( SwingConstants.CENTER );
        
        // Validations ...
        if( value == null )
        {
            setText( "" );
        }
        else
        {
            setText( value.toString() );
        }
        
        return this;
    }
}